<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>

	<body>
		<input class="filer" type="file" value="">
		<button class="btn-top">上传</button>
		<button class="btn-cha">查询</button>

		<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="680" height="520">
		  <param class="id" name="movie" value=""/> 
		  <param name="quality" value="high"/> 
		  <param name="wmode" value="transparent"/> 
		  <param value="true" name="allowFullScreen"/> 
		  <embed class="idt" src="" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="680" height="520" allowfullscreen="true"/>
		</object>
	</body>
	<script type="text/javascript" src="../js/jquery-1.12.4.min.js" ></script>
	<script type="text/javascript">
		
		
		
		$.ajax({
			type:"get",
			url:"https://openapi.iqiyi.com/api/iqiyi/authorize?client_id=516c9a545d4849feb2e4d760b8d64d3c &client_secret=509795f57b746a4ef4fc8ded808d6caf",
			async:true,
			success: function(res) { //成功得到返回时运行
				console.log(eval("("+res+")"));
				var jp = eval("("+res+")").data.access_token;






//				var ulr = 'http://openapi.iqiyi.com/api/file/urllist?access_token='+jp+'&file_id=c69e4760008c4744a26a91bf93d45440';
//				$.ajax({
//					type:"get",
//					url:ulr,
//					async:true,
//					success:function(res){
//						console.log(ulr);
//						console.log(res);
////						var ulr = res;
////						$('.id').attr('value',ulr);
////						$('.idt').attr('src',ulr);
//					},
//					ajaxError: function(a, b, c) {
//						console.log(a); //错误的对象
//						console.log(b); //错误的类型
//						console.log(c); //错误的信息
//					}
//				});
//				//上传
				$.ajax({
					type:'get',
					url:'http://upload.iqiyi.com/openupload',
					async:true,
					data:{
						'filetype':'swf',
						'filesize':'1024',
						'access_token':jp
					},
					success:function(res){
						console.log(res);
						var id = ''+res.data.file_id;
						var tock = ''+res.data.access_token;
						var rel = 'http://openapi.iqiyi.com/api/file/fullStatus?access_token='+tock+'&file_id='+id;

						$('.btn-top').click(function(){
                            var val = $('.filer').value;
                            if(val!=""){
                                $.ajax({
                                    type:"post",
                                    url:res.data.upload_url,
                                    async:true,
                                    data:{
                                        'file_size':'444',
                                        'range':'0',
                                        'file_id':id,
                                        'file':[val]
                                    },
                                    success:function(res){
                                        console.log(res);
                                        console.log(id);
                                    },
                                    ajaxError: function(a, b, c) {
                                        console.log(a); //错误的对象
                                        console.log(b); //错误的类型
                                        console.log(c); //错误的信息
                                    }
                                });
							}else{

							}
						});
                        $('.btn-cha').click(function(){
                            $.ajax({
                                type:'get',
                                url:rel,
                                async:true,
//								data:{
//									'access_token':tock,
//									'file_id':id
//								},
                                success:function(res){
                                    console.log(res);
                                },
                                ajaxError: function(a, b, c) {
                                    console.log(a); //错误的对象
                                    console.log(b); //错误的类型
                                    console.log(c); //错误的信息
                                }
                            })
                        })
					},
					ajaxError: function(a, b, c) {
						console.log(a); //错误的对象
						console.log(b); //错误的类型
						console.log(c); //错误的信息
					}
				})
			},
			ajaxError: function(a, b, c) {
				console.log(a); //错误的对象
				console.log(b); //错误的类型
				console.log(c); //错误的信息
			},
		});
		


		
		
		
	</script>

</html>